var mysql = require('mysql');
var pool = mysql.createPool({
    connectionLimit: 10,
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'ai'
});


const query = async (sql, params) => {
    return await new Promise((resolve, reject) => {
        pool.query(sql, params, function (error, results, fields) {
            if (error) {
                reject(error)
            } else {
                resolve(results)
            }
        });
    })
}

module.exports = query